package com.example.demo.config;


import com.example.demo.model.Result;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;


@Slf4j
@ControllerAdvice
@ResponseBody
public class ExceptionAdvice {    //统一异常处理

//    @ExceptionHandler
//    public Result handle(Exception e){
//        return Result.fail(e.getMessage());      //这是对外部展示错误
//    }

    @ExceptionHandler
    public Result handle(Exception e){
        log.error("发生异常,e:",e);//这是对外部不展示错误
        return Result.fail("内部错误,请联系管理员");
    }
}
